class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-07-21",
      revision: "7014821c65ae46c8270445f8510338a7445f6271"
  version "2021-07-21"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "8525f2cc4d1aa2213628bf88e2f06983dc096e221078e58d4474f34990f8956b"
    sha256 cellar: :any_skip_relocation, big_sur:       "a3200e1a8f9c258ec1306ee85a988fb0760f02c31e6f6a5f4c877b40b6beb7c1"
    sha256 cellar: :any_skip_relocation, catalina:      "febf362e17e5cad8a472e443a3c3d36425169cd4fd390348b4093822dea34840"
    sha256 cellar: :any_skip_relocation, mojave:        "30edb812e3d47afefc323aa0eb3d9b2767a704092c6b2fdb01a6bd24e8a329b1"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
